package com.tkm.advancedFunctions.extensions

import java.io.File

class Person(var name: String, var age: Int) {
    fun print() {
        println("Name: $name, age: $age")
    }

    override fun toString(): String {
        return "Person(name='$name', age=$age)"
    }
}

fun main() {

    val p1 = Person("Dmitry", 30)
    p1.let(::println)
    p1.run(::println)

    //  fun <T> T.also(block: (T) -> Unit): T
    val p2 = p1.also {
        it.age = 30
        it.name = "Omit"
    }

    //  fun <T> T.apply(block: T.() -> Unit): T
    val p3 = p1.apply {
        this.age = 25
        this.name = "Kevin"
    }

    File(".gitignore")
        .inputStream()
        .reader()
        .buffered()
        .use {
            println(it.readLines())
        }
}
